# Auto-generated by leda
import leda
leda.set_interact_mode(leda.StaticPanelInteractMode())
import dataclasses
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import leda
leda.init("matplotlib")
plt.rcParams.update({"figure.max_open_warning": 0})
%%HTML
<!-- Auto-generated by leda -->
<h2>Table of Contents</h2>
<ol type='I'>
<li type='I'><a href='#leda-demo:-matplotlib'>leda demo: matplotlib</a></li>
<ol type='A'>
<li type='A'><a href='#Info'>Info</a></li>
<li type='A'><a href='#Data'>Data</a></li>
<li type='A'><a href='#Visualization'>Visualization</a></li>
<ol type='1'>
<li type='1'><a href='#Simple'>Simple</a></li>
<li type='1'><a href='#Objects-as-Params'>Objects as Params</a></li>
</ol>
</ol>
</ol>
Widgets
Use the %%interact expr0;expr1;... cell magic to set widgets for that cell.
Each expression is of the form x=y, where x becomes the local var of the cell and y can be a:
list to indicate choices for a dropdown widgettuple to indicate values for an int slider (start, stop, and optional step).E.g.:
%%interact column=list(df.columns)
%%interact column=list(df.columns);mult=[1, 2, 3]
%%interact column=list(df.columns);window=(10, 50)
%%interact column=list(df.columns);window=(10, 50, 5)
Table of Contents
Use the %toc line magic to substitute with a table of contents in static mode.
Toggles
Click the Toggle input cells button at the bottom to reveal input cells.
Using randomly generated data (with fixed seed).
df = pd.DataFrame(np.random.RandomState(42).rand(100, 10), columns=list("abcdefghij"))
%%interact column=list(df.columns);mult=[1, 2, 3]
(df[[column]] * mult).plot(figsize=(15, 8), lw=2, title=f"column={column!r}, mult={mult}")
%%interact column=list(df.columns);window=(10, 50, 5)
ax = df[[column]].iloc[-window:].plot(figsize=(15, 8), lw=2,
title=f"column={column!r}, window={window}")
ax